"""
读取yaml文件，并转换成规定格式，即扁平化 yaml
"""
import yaml

def flatmap(config, res=[], last=""):
    """
    递归字典，当value不为字典类型则添加一个set
    """
    for key, value in config.items():
        if isinstance(value, dict):
            flatmap(value, res, key + '.')
        else:
            res.append((last + key, value))
    return res

config = yaml.load(open("sample.yaml", 'r'), yaml.FullLoader)
print(flatmap(config))
    
